Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump up op-sqlite version for react native v0.76 #37

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

tearfulDalvik
Copy link

#35

In React Native 0.76.3, createError from pouchdb-errors would throw an exception. To handle this, I catch all errors. However, this causes specific errors like MISSING_DOC to be converted into a more generic error:
Error.stack getter called with an invalid receiver.

You can see the related code here:
core.ts#L343

@craftzdog
Copy link
Owner

Thanks for the PR! I will review it when I'm back working on my mobile app

@craftzdog
Copy link
Owner

Looks like the Error.stack getter issue has been resolved here:

facebook/hermes#1496 (comment)

But not landed in RN yet?

@craftzdog
Copy link
Owner

Patching createError as the following solves the issue:

function createError(error, reason) {
  var err = new PouchError(error.status, error.name, error.message);
  if (reason !== undefined) {
    err.reason = reason;
  }
  return err;
}

@craftzdog
Copy link
Owner

Created a PR: pouchdb/pouchdb#9009

@tearfulDalvik
Copy link
Author

Sweet, thank you. Shall we wait for pouchdb to make changes, or should we patch it ourselves

@craftzdog
Copy link
Owner

Let's wait for it to be merged.
Could we merge the op-sqlite upgrade part first?

@tearfulDalvik
Copy link
Author

Sure, please proceed

src/core.ts Outdated
finish(null)
}).catch(e => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you revert this 'catching all errors' part?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this catch is important, since it rejects the promise of async execution. If removed, pouchdb.get() will remain unresolved.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean, it is for catching errors thrown from tx.execute?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, or tx.execute will hang

@craftzdog
Copy link
Owner

hmm, trying to run it locally but it seems that Pods are broken:

[!] CocoaPods could not find compatible versions for pod "React-timing":
  In Podfile:
    React-timing (from `../node_modules/react-native/ReactCommon/react/timing`)

Specs satisfying the `React-timing (from `../node_modules/react-native/ReactCommon/react/timing`)` dependency were found, but they required a higher minimum deployment target.
Failed to update boost. Attempting to update the repo instead.
> pod install --repo-update

...

[!] CocoaPods could not find compatible versions for pod "boost":
  In snapshot (Podfile.lock):
    boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`)

  In Podfile:
    boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`)

It seems like you've changed the version of the dependency `boost` and it differs from the version stored in `Pods/Local Podspecs`.
You should run `pod update boost --no-repo-update` to apply changes made locally.
Couldn't install: boost. Updating the Pods project and trying again...
Command `pod install --repo-update` failed.
└─ Cause: This is often due to native package versions mismatching. Try deleting the 'ios/Pods' folder or the 'ios/Podfile.lock' file and running 'npx pod-install' to resolve.

will try generating a project with create-react-native-library again

@craftzdog
Copy link
Owner

Have you tested replications?

@tearfulDalvik
Copy link
Author

#37 (comment)
That's weird, but it's more of a demo problem, not the library.

I did not test replications, just local transactions.

@craftzdog
Copy link
Owner

replications never finish. Maybe another breaking change in RN0.76

@tearfulDalvik
Copy link
Author

tearfulDalvik commented Dec 9, 2024

It could be another unresolved promise, i.e. an unhandled error in the promise, similar to the createError issue we encountered before.

@craftzdog
Copy link
Owner

Yeah, I had to apply the patch to pouchdb-errors both in <ROOT>/node_modules and <ROOT>/examples/node_modules.
PouchDB needs to check the error code as it says:

The above 404 is totally normal. PouchDB is just checking if a remote checkpoint exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants